const { timeHelper, logHelper, deviceHelper, appHelper } = require("../helper");
const { clickUtils } = require("../shizukuUtils");
const xigua_pointMap = require("../pointMap/xigua");
const { phoneNumberMap } = require("../const");
var phoneNumber = phoneNumberMap[deviceHelper.getAndroidId()];
var pointMap = xigua_pointMap[phoneNumber];
function refresh() {
  if (timeHelper.possible(1, 20)) {
    logHelper.log("点击:放映厅");
    clickUtils.clickPointMap(pointMap.放映厅);
    timeHelper.sleep(10, 20);
  } else {
    logHelper.log("点击:我的");
    clickUtils.clickPointMap(pointMap.我的);
    timeHelper.sleep(3, 6);
  }
  logHelper.log("点击:首页");
  clickUtils.clickPointMap(pointMap.首页);
}
function watch() {
  return timeHelper.sleep(2 * 60, 4 * 60);
}

Wang.main = function (max) {
  var max = Number(max || 210);
  if (isNaN(max)) {
    max = 210;
  }
  logHelper.log(`开始看视频,看${max}min`);
  var hasRead = 0;
  var hasReadMin = 0;
  while (hasReadMin < max) {
    refresh();
    var hasWatch = watch();
    hasRead += hasWatch;
    hasReadMin = timeHelper.getMin(hasRead);
    logHelper.log(`已经看了${hasRead}s,${hasReadMin}min`);
  }
  appHelper.goAutojs();
};
